package com.android.fragmentdemo
import android.os.Bundle
import androidx.recyclerview.widget.ItemTouchHelper
import com.android.fragmentdemo.adapters.SlideItemAdapter
import com.hengfoxwolf.commonbase.base.BaseActivity
import com.android.fragmentdemo.databeans.DataFactoryIp
import com.android.fragmentdemo.databinding.ActivitySlipItemBinding
import com.android.fragmentdemo.definervlayoutmanager.SlideItemTouchCallback
import com.android.fragmentdemo.definervlayoutmanager.SlideLayoutManager

class SlipItemActivity : BaseActivity<ActivitySlipItemBinding>() {

    override fun getLayoutId(): Int = R.layout.activity_slip_item

    override fun init(savedInstanceState: Bundle?) {
        val maxVisibleCount = 3
        val mAdapter = SlideItemAdapter(this@SlipItemActivity)
        mAdapter.itemDataSet = DataFactoryIp.createDataSet()
        val mItemTouchCallback = SlideItemTouchCallback(mAdapter, maxVisibleCount)
        val mItemTouchHelper = ItemTouchHelper(mItemTouchCallback)
        mBinding.rvSlideItem.apply {
            layoutManager = SlideLayoutManager(maxVisibleCount, this, mItemTouchHelper)
            adapter = mAdapter
        }
        mItemTouchHelper.attachToRecyclerView(mBinding.rvSlideItem)
    }

}